<!DOCTYPE html><html lang="zh-CN" data-theme="light"><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1"><title>笔记·一个简单的PythonGUI库——PySimpleGUI使用教程 | 沐の空间</title><meta name="keywords" content="Python"><meta name="author" content="White_mu,WhitemuTeam@outlook.com"><meta name="copyright" content="White_mu"><meta name="format-detection" content="telephone=no"><meta name="theme-color" content="#ffffff"><meta name="description" content="介绍PySimpleGUI是一个非常适合小白的Python GUI库，其风格简易，入门简单。官网&#x2F;更多介绍：https:&#x2F;&#x2F;pysimplegui.readthedocs.io 安装首先你的电脑上要提前安装好Python环境，然后在cmd输入以下代码： 1pip install PySimpleGui  等待安装好即可 使用:简单使用：像这篇文章一个极简易上手的 Python GUI 库 - 云+">
<meta property="og:type" content="article">
<meta property="og:title" content="笔记·一个简单的PythonGUI库——PySimpleGUI使用教程">
<meta property="og:url" content="https://muspace.top/posts/54093/index.html">
<meta property="og:site_name" content="沐の空间">
<meta property="og:description" content="介绍PySimpleGUI是一个非常适合小白的Python GUI库，其风格简易，入门简单。官网&#x2F;更多介绍：https:&#x2F;&#x2F;pysimplegui.readthedocs.io 安装首先你的电脑上要提前安装好Python环境，然后在cmd输入以下代码： 1pip install PySimpleGui  等待安装好即可 使用:简单使用：像这篇文章一个极简易上手的 Python GUI 库 - 云+">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://cdn.jsdelivr.net/gh/WhitemuTeam/web-img/img/91694596.jpg">
<meta property="article:published_time" content="2021-07-10T15:00:00.000Z">
<meta property="article:modified_time" content="2021-07-11T03:00:00.000Z">
<meta property="article:author" content="White_mu">
<meta property="article:tag" content="Python">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://cdn.jsdelivr.net/gh/WhitemuTeam/web-img/img/91694596.jpg"><link rel="shortcut icon" href="/img/Oldfavicon.png"><link rel="canonical" href="https://muspace.top/posts/54093/"><link rel="preconnect" href="//cdn.jsdelivr.net"/><link rel="preconnect" href="//www.google-analytics.com" crossorigin=""/><link rel="preconnect" href="//busuanzi.ibruce.info"/><link rel="stylesheet" href="/css/index.css"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free/css/all.min.css" media="print" onload="this.media='all'"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/node-snackbar/dist/snackbar.min.css" media="print" onload="this.media='all'"><script async="async" src="https://www.googletagmanager.com/gtag/js?id=G-ZVRBXJ2DLK"></script><script>window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-ZVRBXJ2DLK');
</script><script>const GLOBAL_CONFIG = { 
  root: '/',
  algolia: undefined,
  localSearch: {"path":"search.xml","languages":{"hits_empty":"找不到您查询的内容：${query}"}},
  translate: undefined,
  noticeOutdate: undefined,
  highlight: {"plugin":"highlighjs","highlightCopy":true,"highlightLang":true},
  copy: {
    success: '复制成功',
    error: '复制错误',
    noSupport: '浏览器不支持'
  },
  relativeDate: {
    homepage: false,
    post: false
  },
  runtime: '天',
  date_suffix: {
    just: '刚刚',
    min: '分钟前',
    hour: '小时前',
    day: '天前',
    month: '个月前'
  },
  copyright: undefined,
  lightbox: 'fancybox',
  Snackbar: {"chs_to_cht":"你已切换为繁体","cht_to_chs":"你已切换为简体","day_to_night":"你已切换为深色模式","night_to_day":"你已切换为浅色模式","bgLight":"#49b1f5","bgDark":"#121212","position":"bottom-left"},
  source: {
    jQuery: 'https://cdn.jsdelivr.net/npm/jquery@latest/dist/jquery.min.js',
    justifiedGallery: {
      js: 'https://cdn.jsdelivr.net/npm/justifiedGallery/dist/js/jquery.justifiedGallery.min.js',
      css: 'https://cdn.jsdelivr.net/npm/justifiedGallery/dist/css/justifiedGallery.min.css'
    },
    fancybox: {
      js: 'https://cdn.jsdelivr.net/npm/@fancyapps/fancybox@latest/dist/jquery.fancybox.min.js',
      css: 'https://cdn.jsdelivr.net/npm/@fancyapps/fancybox@latest/dist/jquery.fancybox.min.css'
    }
  },
  isPhotoFigcaption: true,
  islazyload: false,
  isanchor: false
}</script><script id="config-diff">var GLOBAL_CONFIG_SITE = { 
  isPost: true,
  isHome: false,
  isHighlightShrink: false,
  isToc: true,
  postUpdate: '2021-07-11 11:00:00'
}</script><noscript><style type="text/css">
  #nav {
    opacity: 1
  }
  .justified-gallery img {
    opacity: 1
  }

  #recent-posts time,
  #post-meta time {
    display: inline !important
  }
</style></noscript><script>(win=>{
    win.saveToLocal = {
      set: function setWithExpiry(key, value, ttl) {
        if (ttl === 0) return
        const now = new Date()
        const expiryDay = ttl * 86400000
        const item = {
          value: value,
          expiry: now.getTime() + expiryDay,
        }
        localStorage.setItem(key, JSON.stringify(item))
      },

      get: function getWithExpiry(key) {
        const itemStr = localStorage.getItem(key)

        if (!itemStr) {
          return undefined
        }
        const item = JSON.parse(itemStr)
        const now = new Date()

        if (now.getTime() > item.expiry) {
          localStorage.removeItem(key)
          return undefined
        }
        return item.value
      }
    }
  
    win.getScript = url => new Promise((resolve, reject) => {
      const script = document.createElement('script')
      script.src = url
      script.async = true
      script.onerror = reject
      script.onload = script.onreadystatechange = function() {
        const loadState = this.readyState
        if (loadState && loadState !== 'loaded' && loadState !== 'complete') return
        script.onload = script.onreadystatechange = null
        resolve()
      }
      document.head.appendChild(script)
    })
  
      win.activateDarkMode = function () {
        document.documentElement.setAttribute('data-theme', 'dark')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#0d0d0d')
        }
      }
      win.activateLightMode = function () {
        document.documentElement.setAttribute('data-theme', 'light')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#ffffff')
        }
      }
      const t = saveToLocal.get('theme')
    
          const isDarkMode = window.matchMedia('(prefers-color-scheme: dark)').matches
          const isLightMode = window.matchMedia('(prefers-color-scheme: light)').matches
          const isNotSpecified = window.matchMedia('(prefers-color-scheme: no-preference)').matches
          const hasNoSupport = !isDarkMode && !isLightMode && !isNotSpecified

          if (t === undefined) {
            if (isLightMode) activateLightMode()
            else if (isDarkMode) activateDarkMode()
            else if (isNotSpecified || hasNoSupport) {
              const now = new Date()
              const hour = now.getHours()
              const isNight = hour <= 6 || hour >= 18
              isNight ? activateDarkMode() : activateLightMode()
            }
            window.matchMedia('(prefers-color-scheme: dark)').addListener(function (e) {
              if (saveToLocal.get('theme') === undefined) {
                e.matches ? activateDarkMode() : activateLightMode()
              }
            })
          } else if (t === 'light') activateLightMode()
          else activateDarkMode()
        
      const asideStatus = saveToLocal.get('aside-status')
      if (asideStatus !== undefined) {
        if (asideStatus === 'hide') {
          document.documentElement.classList.add('hide-aside')
        } else {
          document.documentElement.classList.remove('hide-aside')
        }
      }
    })(window)</script><link rel="stylesheet" href="//at.alicdn.com/t/font_2594570_i6c7w02fsw.css"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/font-awesome/css/font-awesome.min.css"><style>#aside-content .card-info .card-info-social-icons i { position: inherit !important}</style><style>#aside-content .card-info .button--animated i { position: inherit !important}</style><script src="/live2d-widget/autoload.js"></script><link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/zyoushuo/Blog@latest/hexo/css/loading_style_1.css" ><link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/zyoushuo/Blog@latest/hexo/css/loading_style_2.css" ><script src="/live2d-widget/autoload.js"></script><!-- hexo injector head_end start --><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/hexo-butterfly-artitalk-pro/lib/card.css" media="defer" onload="this.media='all'"><!-- hexo injector head_end end --><meta name="generator" content="Hexo 5.4.0"><link rel="alternate" href="/atom.xml" title="沐の空间" type="application/atom+xml">
</head><body>
<div id='loader'>
    
    <div class="outer_box">
    <div class='loader_overlay'></div>
    <div class='loader_cogs'>
        <div class='loader_cogs__top'>
            <div class='top_part'></div>
            <div class='top_part'></div>
            <div class='top_part'></div>
            <div class='top_hole'></div>
        </div>
        <div class='loader_cogs__left'>
            <div class='left_part'></div>
            <div class='left_part'></div>
            <div class='left_part'></div>
            <div class='left_hole'></div>
        </div>
        <div class='loader_cogs__bottom'>
            <div class='bottom_part'></div>
            <div class='bottom_part'></div>
            <div class='bottom_part'></div>
            <div class='bottom_hole'></div>
        </div>
        <p style="text-align:center">&nbsp;&nbsp;&nbsp;loading...</p>
    </div>
    </div>
  
</div>

<script>
  var endLoading = function () {
    document.body.style.overflow = 'auto';
    document.getElementById('loader').classList.add("loading");
  }
  window.addEventListener('load',endLoading);
</script>
<div id="web_bg"></div><div id="sidebar"><div id="menu-mask"></div><div id="sidebar-menus"><div class="author-avatar"><img class="avatar-img" src="/img/head.png" onerror="onerror=null;src='/img/friend_404.gif'" alt="avatar"/></div><div class="site-data"><div class="data-item is-center"><div class="data-item-link"><a href="/archives/"><div class="headline">文章</div><div class="length-num">49</div></a></div></div><div class="data-item is-center"><div class="data-item-link"><a href="/tags/"><div class="headline">标签</div><div class="length-num">20</div></a></div></div><div class="data-item is-center"><div class="data-item-link"><a href="/categories/"><div class="headline">分类</div><div class="length-num">20</div></a></div></div></div><hr/><div class="menus_items"><div class="menus_item"><a class="site-page" href="/messageboard/"><i class="fa-fw fa fa-paper-plane"></i><span> 留言板</span></a></div><div class="menus_item"><a class="site-page" href="/artitalk/"><i class="fa-fw iconfont icon-sticky-note-line"></i><span> 碎碎念</span></a></div><div class="menus_item"><a class="site-page" href="javascript:void(0);"><i class="fa-fw fa-fw fa fa-book"></i><span> 文章</span><i class="fas fa-chevron-down expand"></i></a><ul class="menus_item_child"><li><a class="site-page" href="/tags/"><i class="fa-fw fa fa-tags"></i><span> 标签</span></a></li><li><a class="site-page" href="/categories/"><i class="fa-fw fa fa-folder-open"></i><span> 分类</span></a></li><li><a class="site-page" href="/archives/"><i class="fa-fw fa fa-archive"></i><span> 时间轴</span></a></li></ul></div><div class="menus_item"><a class="site-page" href="javascript:void(0);"><i class="fa-fw fa fa-link"></i><span> 链接</span><i class="fas fa-chevron-down expand"></i></a><ul class="menus_item_child"><li><a class="site-page" href="/link/"><i class="fa-fw fa fa-users"></i><span> 友情链接</span></a></li><li><a class="site-page" target="_blank" rel="noopener" href="https://space.bilibili.com/97020216"><i class="fa-fw iconfont icon-bilibili-line"></i><span> Bilibili个人主页</span></a></li></ul></div><div class="menus_item"><a class="site-page" href="javascript:void(0);"><i class="fa-fw fa fa-list"></i><span> 菜单</span><i class="fas fa-chevron-down expand"></i></a><ul class="menus_item_child"><li><a class="site-page" href="/about/"><i class="fa-fw fa fa-heart"></i><span> 关于</span></a></li><li><a class="site-page" href="/lab/ProgrammersYellowCalender"><i class="fa-fw iconfont icon-calendar-2-line"></i><span> 程序员老黄历</span></a></li><li><a class="site-page" href="/jump/"><i class="fa-fw iconfont icon-web"></i><span> 文章导航</span></a></li></ul></div><div class="menus_item"><a class="site-page" target="_blank" rel="noopener" href="https://travellings.link"><i class="fa-fw fa fa-subway"></i><span> 开往</span></a></div></div></div></div><div class="post" id="body-wrap"><header class="post-bg" id="page-header" style="background-image: url('https://cdn.jsdelivr.net/gh/WhitemuTeam/web-img/img/91694596.jpg')"><nav id="nav"><span id="blog_name"><a id="site-name" href="/">沐の空间</a></span><div id="menus"><div id="search-button"><a class="site-page social-icon search"><i class="fas fa-search fa-fw"></i><span> 搜索</span></a></div><div class="menus_items"><div class="menus_item"><a class="site-page" href="/messageboard/"><i class="fa-fw fa fa-paper-plane"></i><span> 留言板</span></a></div><div class="menus_item"><a class="site-page" href="/artitalk/"><i class="fa-fw iconfont icon-sticky-note-line"></i><span> 碎碎念</span></a></div><div class="menus_item"><a class="site-page" href="javascript:void(0);"><i class="fa-fw fa-fw fa fa-book"></i><span> 文章</span><i class="fas fa-chevron-down expand"></i></a><ul class="menus_item_child"><li><a class="site-page" href="/tags/"><i class="fa-fw fa fa-tags"></i><span> 标签</span></a></li><li><a class="site-page" href="/categories/"><i class="fa-fw fa fa-folder-open"></i><span> 分类</span></a></li><li><a class="site-page" href="/archives/"><i class="fa-fw fa fa-archive"></i><span> 时间轴</span></a></li></ul></div><div class="menus_item"><a class="site-page" href="javascript:void(0);"><i class="fa-fw fa fa-link"></i><span> 链接</span><i class="fas fa-chevron-down expand"></i></a><ul class="menus_item_child"><li><a class="site-page" href="/link/"><i class="fa-fw fa fa-users"></i><span> 友情链接</span></a></li><li><a class="site-page" target="_blank" rel="noopener" href="https://space.bilibili.com/97020216"><i class="fa-fw iconfont icon-bilibili-line"></i><span> Bilibili个人主页</span></a></li></ul></div><div class="menus_item"><a class="site-page" href="javascript:void(0);"><i class="fa-fw fa fa-list"></i><span> 菜单</span><i class="fas fa-chevron-down expand"></i></a><ul class="menus_item_child"><li><a class="site-page" href="/about/"><i class="fa-fw fa fa-heart"></i><span> 关于</span></a></li><li><a class="site-page" href="/lab/ProgrammersYellowCalender"><i class="fa-fw iconfont icon-calendar-2-line"></i><span> 程序员老黄历</span></a></li><li><a class="site-page" href="/jump/"><i class="fa-fw iconfont icon-web"></i><span> 文章导航</span></a></li></ul></div><div class="menus_item"><a class="site-page" target="_blank" rel="noopener" href="https://travellings.link"><i class="fa-fw fa fa-subway"></i><span> 开往</span></a></div></div><div id="toggle-menu"><a class="site-page"><i class="fas fa-bars fa-fw"></i></a></div></div></nav><div id="post-info"><h1 class="post-title">笔记·一个简单的PythonGUI库——PySimpleGUI使用教程</h1><div id="post-meta"><div class="meta-firstline"><span class="post-meta-date"><i class="far fa-calendar-alt fa-fw post-meta-icon"></i><span class="post-meta-label">发表于</span><time class="post-meta-date-created" datetime="2021-07-10T15:00:00.000Z" title="发表于 2021-07-10 23:00:00">2021-07-10</time><span class="post-meta-separator">|</span><i class="fas fa-history fa-fw post-meta-icon"></i><span class="post-meta-label">更新于</span><time class="post-meta-date-updated" datetime="2021-07-11T03:00:00.000Z" title="更新于 2021-07-11 11:00:00">2021-07-11</time></span><span class="post-meta-categories"><span class="post-meta-separator">|</span><i class="fas fa-inbox fa-fw post-meta-icon"></i><a class="post-meta-categories" href="/categories/Python/">Python</a></span></div><div class="meta-secondline"><span class="post-meta-separator">|</span><span class="post-meta-wordcount"><i class="far fa-file-word fa-fw post-meta-icon"></i><span class="post-meta-label">字数总计:</span><span class="word-count">1.8k</span><span class="post-meta-separator">|</span><i class="far fa-clock fa-fw post-meta-icon"></i><span class="post-meta-label">阅读时长:</span><span>7分钟</span></span><span class="post-meta-separator">|</span><span class="post-meta-pv-cv"><i class="far fa-eye fa-fw post-meta-icon"></i><span class="post-meta-label">阅读量:</span><span id="busuanzi_value_page_pv"></span></span></div></div></div></header><main class="layout" id="content-inner"><div id="post"><article class="post-content" id="article-container"><h1 id="介绍"><a href="#介绍" class="headerlink" title="介绍"></a>介绍</h1><p>PySimpleGUI是一个非常适合小白的Python GUI库，其风格简易，入门简单。官网/更多介绍：<a target="_blank" rel="noopener" href="https://pysimplegui.readthedocs.io/">https://pysimplegui.readthedocs.io</a></p>
<h1 id="安装"><a href="#安装" class="headerlink" title="安装"></a>安装</h1><p>首先你的电脑上要提前安装好Python环境，然后在cmd输入以下代码：</p>
<figure class="highlight powershell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">pip install PySimpleGui</span><br></pre></td></tr></table></figure>

<p>等待安装好即可</p>
<h1 id="使用"><a href="#使用" class="headerlink" title="使用:"></a>使用:</h1><h2 id="简单使用："><a href="#简单使用：" class="headerlink" title="简单使用："></a>简单使用：</h2><p>像这篇文章<a target="_blank" rel="noopener" href="https://cloud.tencent.com/developer/article/1588375">一个极简易上手的 Python GUI 库 - 云+社区 - 腾讯云 (tencent.com)</a>讲的一样，先画出GUI的草图</p>
<p>这里注意要加上它们的属性（第?行，文本/输入框/按钮）</p>
<p><img src="https://i.bmp.ovh/imgs/2021/07/024e316242ffeac3.jpg"></p>
<p>然后我们就要开始写代码了。</p>
<p>打开Python文件，导入库：</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">import</span> PySimpleGUI <span class="keyword">as</span> sg</span><br></pre></td></tr></table></figure>

<p>我们看到第一行只有个文本，所以我们使用：</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">sg.Text(<span class="string">&#x27;Enter a number&#x27;</span>) <span class="comment">#sg.Text(&#x27;文本&#x27;)</span></span><br></pre></td></tr></table></figure>

<p>所以其用法为：</p>
<p>第二行有个输入框，所以我们使用：</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">sg.Input()</span><br></pre></td></tr></table></figure>

<p>第三行有个”OK”按钮，所以我们使用：</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">sg.OK()</span><br></pre></td></tr></table></figure>

<p>将以上代码合起来，形成：</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">layout = [ [sg.Text(<span class="string">&#x27;Enter a Number&#x27;</span>)],</span><br><span class="line">           [sg.Input()],</span><br><span class="line">           [sg.OK()] ]</span><br></pre></td></tr></table></figure>

<p>现在我们要生成GUI窗口：</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">event, (number,) = sg.Window(<span class="string">&#x27;Enter a number example&#x27;</span>).Layout(layout).Read()</span><br><span class="line"><span class="comment">#sg.Window(&#x27;窗口标题&#x27;)</span></span><br></pre></td></tr></table></figure>

<p>按下OK后我们要弹出一个窗口：</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">sg.Popup(event, number)</span><br></pre></td></tr></table></figure>

<p>其中event表示事件，在按下OK后其值为OK，number表示User在文本框输入的数据</p>
<p>所以弹出的窗口就有两值：OK和User输入的数据</p>
<p>将上述代码合起来：</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">import</span> PySimpleGUI <span class="keyword">as</span> sg</span><br><span class="line">layout = [ [sg.Text(<span class="string">&#x27;Enter a Number&#x27;</span>)],</span><br><span class="line">           [sg.Input()],</span><br><span class="line">           [sg.OK()] ]</span><br><span class="line">event, (number,) = sg.Window(<span class="string">&#x27;Enter a number example&#x27;</span>).Layout(layout).Read()</span><br><span class="line">sg.Popup(event, number)</span><br></pre></td></tr></table></figure>

<p>运行后得到：</p>
<p><img src="https://i.bmp.ovh/imgs/2021/07/9218483a10623753.png"></p>
<p>在输入框中输入12，弹出:</p>
<p>OK</p>
<p>12</p>
<h2 id="进阶教程："><a href="#进阶教程：" class="headerlink" title="进阶教程："></a>进阶教程：</h2><p>详见<a target="_blank" rel="noopener" href="https://cloud.tencent.com/developer/article/1588375">一个极简易上手的 Python GUI 库 - 云+社区 - 腾讯云 (tencent.com)</a>，这里不细谈</p>
<h2 id="实例"><a href="#实例" class="headerlink" title="实例:"></a>实例:</h2><p>假如我们想要做像<a target="_blank" rel="noopener" href="https://www.bilibili.com/video/BV1Q64y1975x">https://www.bilibili.com/video/BV1Q64y1975x</a> 一样的答题器，那我们首先还是要画草图</p>
<p>这里直接引用程序主界面：</p>
<p><img src="https://i.bmp.ovh/imgs/2021/07/c3e34428a7b25b53.png"></p>
<p>你可以看到左边布局大致分为（改）：</p>
<p>第一行（标题-文本）：White_mu真分数的答题器</p>
<p>第二行（文本）：White_mu又称为（25分）</p>
<p>第三行（原：按钮/改：输入框）注：PySimpleGUI也可实现此模板，但这里简化</p>
<p>…</p>
<p>第十一行（按钮）：提交</p>
<p>于是我们可以写下此代码：</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line">layout = [[sg.Text(<span class="string">&#x27;欢迎使用White_mu的水粉检测器&#x27;</span>)], <span class="comment">#窗口页面所含内容</span></span><br><span class="line">          [sg.Text(<span class="string">&#x27;共4小题，100分&#x27;</span>)], <span class="comment">#文本</span></span><br><span class="line">          [sg.Text(<span class="string">&#x27;1.请输入White_mu的中文网名&#x27;</span>)],</span><br><span class="line">          [sg.Input()], <span class="comment">#输入框，且输入的值在value[0]中</span></span><br><span class="line">          [sg.Text(<span class="string">&#x27;2.请输入White_mu的工作室口号&#x27;</span>)],</span><br><span class="line">          [sg.Input()],</span><br><span class="line">          [sg.Text(<span class="string">&#x27;3.请输入White_mu的B站UID&#x27;</span>)],</span><br><span class="line">          [sg.Input()],</span><br><span class="line">          [sg.Text(<span class="string">&#x27;4.请输入White_mu的个人主页链接&#x27;</span>)],</span><br><span class="line">          [sg.Input()],</span><br><span class="line">          [sg.Button(<span class="string">&#x27;提交&#x27;</span>, key=<span class="string">&#x27;submit&#x27;</span>)]] <span class="comment">#按钮：提交，key=&#x27;submit&#x27;：按下后event为submit</span></span><br></pre></td></tr></table></figure>

<p>现在要生成GUI，导入库，生成GUI，与上述代码合并：</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">import</span> PySimpleGUI <span class="keyword">as</span> sg <span class="comment">#导入PySimpleGUI函数并简化为sg以创立GUI窗口</span></span><br><span class="line"></span><br><span class="line">layout = [[sg.Text(<span class="string">&#x27;欢迎使用White_mu的水粉检测器&#x27;</span>)], <span class="comment">#窗口页面所含内容</span></span><br><span class="line">          [sg.Text(<span class="string">&#x27;共4小题，100分&#x27;</span>)], <span class="comment">#文本</span></span><br><span class="line">          [sg.Text(<span class="string">&#x27;1.请输入White_mu的中文网名&#x27;</span>)],</span><br><span class="line">          [sg.Input()], <span class="comment">#输入框，且输入的值在value[0]中</span></span><br><span class="line">          [sg.Text(<span class="string">&#x27;2.请输入White_mu的工作室口号&#x27;</span>)],</span><br><span class="line">          [sg.Input()],</span><br><span class="line">          [sg.Text(<span class="string">&#x27;3.请输入White_mu的B站UID&#x27;</span>)],</span><br><span class="line">          [sg.Input()],</span><br><span class="line">          [sg.Text(<span class="string">&#x27;4.请输入White_mu的个人主页链接&#x27;</span>)],</span><br><span class="line">          [sg.Input()],</span><br><span class="line">          [sg.Button(<span class="string">&#x27;提交&#x27;</span>, key=<span class="string">&#x27;submit&#x27;</span>)]] <span class="comment">#按钮：提交，key=&#x27;submit&#x27;：按下后event为submit</span></span><br><span class="line"></span><br><span class="line">window = sg.Window(<span class="string">&#x27;White_mu的水粉检测器&#x27;</span>, layout, icon=<span class="string">r&#x27;LOGO.ico&#x27;</span>) <span class="comment">#设置窗口</span></span><br></pre></td></tr></table></figure>

<p>注：这里可以设置窗口的图标，只需要在layout后面加个<code>icon=r&#39;xxx.ico&#39;</code>即可</p>
<p>要计算分数，我们就要写一个计算分数的函数：</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line"><span class="function"><span class="keyword">def</span> <span class="title">check</span>(<span class="params">q1, q2, q3, q4</span>):</span> <span class="comment">#建立check函数以计算分数</span></span><br><span class="line">    s=<span class="number">0</span></span><br><span class="line">    <span class="keyword">if</span> q1==<span class="string">&#x27;白沐&#x27;</span>:</span><br><span class="line">        s=s+<span class="number">25</span></span><br><span class="line">    <span class="keyword">if</span> q2==<span class="string">&#x27;咕~咕~咕~&#x27;</span>:</span><br><span class="line">        s=s+<span class="number">25</span></span><br><span class="line">    <span class="keyword">if</span> q3==<span class="string">&#x27;97020216&#x27;</span>:</span><br><span class="line">        s=s+<span class="number">25</span></span><br><span class="line">    <span class="keyword">if</span> q4==<span class="string">&#x27;https://muspace.top&#x27;</span>:</span><br><span class="line">        s=s+<span class="number">25</span></span><br><span class="line">    <span class="keyword">return</span> s</span><br></pre></td></tr></table></figure>

<p>为了计算分数，我们还要提取User输入的信息：</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">event, value = window.Read() <span class="comment">#读取输入值</span></span><br></pre></td></tr></table></figure>

<p>现在我们要运行check函数并导入User输入的信息：</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">if</span> event == <span class="string">&#x27;submit&#x27;</span>: <span class="comment">#当event为submit时，即按下提交按钮时</span></span><br><span class="line">	s = check(value[<span class="number">0</span>], value[<span class="number">1</span>], value[<span class="number">2</span>],value[<span class="number">3</span>]) <span class="comment">#运行check函数，并导入输入框的内容，分数值输出到s中</span></span><br></pre></td></tr></table></figure>

<p>像上图右手边做一个分数反馈弹出窗口：</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">if</span> s==<span class="number">100</span>:</span><br><span class="line">	sg.popup(<span class="string">&#x27;您的分数为100，恭喜您是White_mu的真粉丝，可以领个粉丝牌了&#x27;</span>, icon=<span class="string">r&#x27;icon=LOGO.ico&#x27;</span>) <span class="comment">#弹出窗口</span></span><br><span class="line"><span class="keyword">else</span>:</span><br><span class="line">	sg.popup(<span class="string">&#x27;您的分数为&#x27;</span>, s,<span class="string">&#x27;还是/remake吧&#x27;</span>, icon=<span class="string">r&#x27;icon=LOGO.ico&#x27;</span>)</span><br></pre></td></tr></table></figure>

<p>与上述代码合并：</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">if</span> event == <span class="string">&#x27;submit&#x27;</span>: <span class="comment">#当event为submit时，即按下提交按钮时</span></span><br><span class="line">	s = check(value[<span class="number">0</span>], value[<span class="number">1</span>], value[<span class="number">2</span>],value[<span class="number">3</span>]) <span class="comment">#运行check函数，并导入输入框的内容</span></span><br><span class="line">	<span class="keyword">if</span> s==<span class="number">100</span>:</span><br><span class="line">		sg.popup(<span class="string">&#x27;您的分数为100，恭喜您是White_mu的真粉丝，可以领个粉丝牌了&#x27;</span>, icon=<span class="string">r&#x27;icon=LOGO.ico&#x27;</span>) <span class="comment">#弹出窗口</span></span><br><span class="line">	<span class="keyword">else</span>:</span><br><span class="line">		sg.popup(<span class="string">&#x27;您的分数为&#x27;</span>, s,<span class="string">&#x27;还是/remake吧&#x27;</span>, icon=<span class="string">r&#x27;icon=LOGO.ico&#x27;</span>)</span><br></pre></td></tr></table></figure>

<p>最终现在我们可以得到：</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br></pre></td><td class="code"><pre><span class="line"><span class="function"><span class="keyword">def</span> <span class="title">check</span>(<span class="params">q1, q2, q3, q4</span>):</span> <span class="comment">#建立check函数以计算分数</span></span><br><span class="line">    s=<span class="number">0</span></span><br><span class="line">    <span class="keyword">if</span> q1==<span class="string">&#x27;白沐&#x27;</span>:</span><br><span class="line">        s=s+<span class="number">25</span></span><br><span class="line">    <span class="keyword">if</span> q2==<span class="string">&#x27;咕~咕~咕~&#x27;</span>:</span><br><span class="line">        s=s+<span class="number">25</span></span><br><span class="line">    <span class="keyword">if</span> q3==<span class="string">&#x27;97020216&#x27;</span>:</span><br><span class="line">        s=s+<span class="number">25</span></span><br><span class="line">    <span class="keyword">if</span> q4==<span class="string">&#x27;https://muspace.top&#x27;</span>:</span><br><span class="line">        s=s+<span class="number">25</span></span><br><span class="line">    <span class="keyword">return</span> s</span><br><span class="line"></span><br><span class="line"><span class="keyword">import</span> PySimpleGUI <span class="keyword">as</span> sg <span class="comment">#导入PySimpleGUI函数并简化为sg以创立GUI窗口</span></span><br><span class="line"></span><br><span class="line">layout = [[sg.Text(<span class="string">&#x27;欢迎使用White_mu的水粉检测器&#x27;</span>)], <span class="comment">#窗口页面所含内容</span></span><br><span class="line">          [sg.Text(<span class="string">&#x27;共4小题，100分&#x27;</span>)], <span class="comment">#文本</span></span><br><span class="line">          [sg.Text(<span class="string">&#x27;1.请输入White_mu的中文网名&#x27;</span>)],</span><br><span class="line">          [sg.Input()], <span class="comment">#输入框，且输入的值在value[0]中</span></span><br><span class="line">          [sg.Text(<span class="string">&#x27;2.请输入White_mu的工作室口号&#x27;</span>)],</span><br><span class="line">          [sg.Input()],</span><br><span class="line">          [sg.Text(<span class="string">&#x27;3.请输入White_mu的B站UID&#x27;</span>)],</span><br><span class="line">          [sg.Input()],</span><br><span class="line">          [sg.Text(<span class="string">&#x27;4.请输入White_mu的个人主页链接&#x27;</span>)],</span><br><span class="line">          [sg.Input()],</span><br><span class="line">          [sg.Button(<span class="string">&#x27;提交&#x27;</span>, key=<span class="string">&#x27;submit&#x27;</span>)]] <span class="comment">#按钮：提交，key=&#x27;submit&#x27;：按下后event为submit</span></span><br><span class="line"></span><br><span class="line">window = sg.Window(<span class="string">&#x27;White_mu的水粉检测器&#x27;</span>, layout, icon=<span class="string">r&#x27;LOGO.ico&#x27;</span>) <span class="comment">#设置窗口</span></span><br><span class="line">event, value = window.Read() <span class="comment">#读取输入值</span></span><br><span class="line"></span><br><span class="line"><span class="keyword">if</span> event == <span class="string">&#x27;submit&#x27;</span>: <span class="comment">#当event为submit时，即按下提交按钮时</span></span><br><span class="line">	s = check(value[<span class="number">0</span>], value[<span class="number">1</span>], value[<span class="number">2</span>],value[<span class="number">3</span>]) <span class="comment">#运行check函数，并导入输入框的内容</span></span><br><span class="line">	<span class="keyword">if</span> s==<span class="number">100</span>:</span><br><span class="line">		sg.popup(<span class="string">&#x27;您的分数为100，恭喜您是White_mu的真粉丝，可以领个粉丝牌了&#x27;</span>) <span class="comment">#弹出窗口</span></span><br><span class="line">	<span class="keyword">else</span>:</span><br><span class="line">		sg.popup(<span class="string">&#x27;您的分数为&#x27;</span>, s,<span class="string">&#x27;还是/remake吧&#x27;</span>)</span><br></pre></td></tr></table></figure>

<p>运行此程序：</p>
<p><img src="https://i.bmp.ovh/imgs/2021/07/ecdc9c74f30f36a2.png"></p>
<p>输入正确答案：</p>
<p><img src="https://i.bmp.ovh/imgs/2021/07/1dbf2723d0bd1476.png"></p>
<p>输入错误答案：</p>
<p><img src="https://i.bmp.ovh/imgs/2021/07/43911595c88693f4.png"></p>
<p>程序运行非常成功，现在我们要将此程序打包成exe文件</p>
<p>在程序根目录打开cmd，输入（需提前安装pyinstaller库）：</p>
<figure class="highlight powershell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">pyinstaller <span class="operator">-F</span> <span class="literal">-i</span> LOGO.ico <span class="literal">-w</span> gui.py</span><br></pre></td></tr></table></figure>

<p>注意：程序LOGO要用到LOGO.ico，所以我们要在生成的exe文件中放入LOGO.ico</p>
<p>​          这里要用到-w，因为程序运行时不需要用到命令提示符，加上-w，隐藏它</p>
<p>​          由于exe根目录迟早要放LOGO.ico的，所以-F函数可以省略，让程序运行得更快</p>
<p>-End-</p>
</article><div class="post-copyright"><div class="post-copyright__author"><span class="post-copyright-meta">文章作者: </span><span class="post-copyright-info"><a href="mailto:WhitemuTeam@outlook.com">White_mu</a></span></div><div class="post-copyright__type"><span class="post-copyright-meta">文章链接: </span><span class="post-copyright-info"><a href="https://muspace.top/posts/54093/">https://muspace.top/posts/54093/</a></span></div><div class="post-copyright__notice"><span class="post-copyright-meta">版权声明: </span><span class="post-copyright-info">本博客所有文章除特别声明外，均采用 <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/" target="_blank">CC BY-NC-SA 4.0</a> 许可协议。转载请注明来自 <a href="https://muspace.top" target="_blank">沐の空间</a>！</span></div></div><div class="tag_share"><div class="post-meta__tag-list"><a class="post-meta__tags" href="/tags/Python/">Python</a></div><div class="post_share"><div class="social-share" data-image="https://cdn.jsdelivr.net/gh/WhitemuTeam/web-img/img/91694596.jpg" data-sites="facebook,twitter,wechat,weibo,qq"></div><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/social-share.js/dist/css/share.min.css" media="print" onload="this.media='all'"><script src="https://cdn.jsdelivr.net/npm/social-share.js/dist/js/social-share.min.js" defer></script></div></div><div class="post-reward"><div class="reward-button button--animated"><i class="fas fa-qrcode"></i> 打赏</div><div class="reward-main"><ul class="reward-all"><li class="reward-item"><a href="https://cdn.jsdelivr.net/gh/WhitemuTeam/web-img/WeChat.png" target="_blank"><img class="post-qr-code-img" src="https://cdn.jsdelivr.net/gh/WhitemuTeam/web-img/WeChat.png" alt="wechat"/></a><div class="post-qr-code-desc">wechat</div></li><li class="reward-item"><a href="https://cdn.jsdelivr.net/gh/WhitemuTeam/web-img/alipay.png" target="_blank"><img class="post-qr-code-img" src="https://cdn.jsdelivr.net/gh/WhitemuTeam/web-img/alipay.png" alt="alipay"/></a><div class="post-qr-code-desc">alipay</div></li></ul></div></div><nav class="pagination-post" id="pagination"><div class="prev-post pull-left"><a href="/posts/6107/"><img class="prev-cover" src="https://cdn.jsdelivr.net/gh/WhitemuTeam/web-img/img/90399055.jpg" onerror="onerror=null;src='/img/404.jpg'" alt="cover of previous post"><div class="pagination-info"><div class="label">上一篇</div><div class="prev_info">如何将酷狗的.kgma文件转换为.flac格式</div></div></a></div><div class="next-post pull-right"><a href="/posts/39255/"><img class="next-cover" src="https://cdn.jsdelivr.net/gh/WhitemuTeam/web-img/img/1622280460878.png" onerror="onerror=null;src='/img/404.jpg'" alt="cover of next post"><div class="pagination-info"><div class="label">下一篇</div><div class="next_info">如何下载网页上的音乐</div></div></a></div></nav><hr/><div id="post-comment"><div class="comment-head"><div class="comment-headline"><i class="fas fa-comments fa-fw"></i><span> 评论</span></div></div><div class="comment-wrap"><div><div id="waline-wrap"></div></div></div></div></div><div class="aside-content" id="aside-content"><div class="sticky_layout"><div class="card-widget" id="card-toc"><div class="item-headline"><i class="fas fa-stream"></i><span>目录</span></div><div class="toc-content"><ol class="toc"><li class="toc-item toc-level-1"><a class="toc-link" href="#%E4%BB%8B%E7%BB%8D"><span class="toc-number">1.</span> <span class="toc-text">介绍</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#%E5%AE%89%E8%A3%85"><span class="toc-number">2.</span> <span class="toc-text">安装</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#%E4%BD%BF%E7%94%A8"><span class="toc-number">3.</span> <span class="toc-text">使用:</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#%E7%AE%80%E5%8D%95%E4%BD%BF%E7%94%A8%EF%BC%9A"><span class="toc-number">3.1.</span> <span class="toc-text">简单使用：</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E8%BF%9B%E9%98%B6%E6%95%99%E7%A8%8B%EF%BC%9A"><span class="toc-number">3.2.</span> <span class="toc-text">进阶教程：</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E5%AE%9E%E4%BE%8B"><span class="toc-number">3.3.</span> <span class="toc-text">实例:</span></a></li></ol></li></ol></div></div></div></div></main><footer id="footer"><div id="footer-wrap"><div class="copyright">&copy;2020 - 2021 By White_mu</div><div class="framework-info"><span>框架 </span><a target="_blank" rel="noopener" href="https://hexo.io">Hexo</a><span class="footer-separator">|</span><span>主题 </span><a target="_blank" rel="noopener" href="https://github.com/jerryc127/hexo-theme-butterfly">Butterfly</a></div><div class="footer_custom_text">单程孤舟，出云入霞，如歌如吟。</div></div></footer></div><div id="rightside"><div id="rightside-config-hide"><button id="readmode" type="button" title="阅读模式"><i class="fas fa-book-open"></i></button><button id="darkmode" type="button" title="浅色和深色模式转换"><i class="fas fa-adjust"></i></button><button id="hide-aside-btn" type="button" title="单栏和双栏切换"><i class="fas fa-arrows-alt-h"></i></button></div><div id="rightside-config-show"><button id="rightside_config" type="button" title="设置"><i class="fas fa-cog fa-spin"></i></button><button class="close" id="mobile-toc-button" type="button" title="目录"><i class="fas fa-list-ul"></i></button><a id="to_comment" href="#post-comment" title="直达评论"><i class="fas fa-comments"></i></a><button id="go-up" type="button" title="回到顶部"><i class="fas fa-arrow-up"></i></button></div></div><div id="local-search"><div class="search-dialog"><div class="search-dialog__title" id="local-search-title">本地搜索</div><div id="local-input-panel"><div id="local-search-input"><div class="local-search-box"><input class="local-search-box--input" placeholder="搜索文章" type="text"/></div></div></div><hr/><div id="local-search-results"></div><span class="search-close-button"><i class="fas fa-times"></i></span></div><div id="search-mask"></div></div><div><script src="/js/utils.js"></script><script src="/js/main.js"></script><script src="https://cdn.jsdelivr.net/npm/instant.page/instantpage.min.js" type="module"></script><script src="https://cdn.jsdelivr.net/npm/node-snackbar/dist/snackbar.min.js"></script><script src="/js/search/local-search.js"></script><script>var preloader = {
  endLoading: () => {
    document.body.style.overflow = 'auto';
    document.getElementById('loading-box').classList.add("loaded")
  },
  initLoading: () => {
    document.body.style.overflow = '';
    document.getElementById('loading-box').classList.remove("loaded")

  }
}
window.addEventListener('load',preloader.endLoading())</script><div class="js-pjax"><script>function loadWaline () {
  function initWaline () {
    let initData = {
      el: '#waline-wrap',
      serverURL: 'https://mywaline-kohl.vercel.app',
      avatar: 'monsterid',
      path: location.pathname,
      emojiCDN: 'https://cdn.jsdelivr.net/gh/walinejs/emojis@1.0.0/bilibili',
      emojiMaps: "",
    }
    
    if (true) {
      const otherData = {"langMode":{"admin":"沐沐"},"dark":"auto","emoji":["https://cdn.jsdelivr.net/gh/walinejs/emojis@1.0.0/bilibili","https://cdn.jsdelivr.net/gh/walinejs/emojis@1.0.0/weibo"]}
      initData = Object.assign(initData, otherData)
    }
    
    const waline = new Waline(initData)
  }

  if (typeof Waline === 'function') initWaline() 
  else getScript('https://cdn.jsdelivr.net/npm/@waline/client/dist/Waline.min.js').then(initWaline)
}

if ('Waline' === 'Waline' || !false) {
  if (false) btf.loadComment(document.getElementById('waline-wrap'),loadWaline)
  else setTimeout(loadWaline, 0)
} else {
  function loadOtherComment () {
    loadWaline()
  }
}</script></div><link rel="stylesheet" href="/css/muspace.css"><script async data-pjax src="/js/randombg.js"></script><script async data-pjax src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script></div><!-- hexo injector body_end start --><script data-pjax>
  function card_artitalk_injector_config(){
    var parent_div_git = document.getElementsByClassName('sticky_layout')[0];
    var item_html = '<div class="card-widget card-shuo"><div class="card-content" style="height:auto;min-height:280px;"><div class="item-headline"><i class="fas fa-comments"></i><span><a href="/artitalk/" title="artitalk page link">碎碎念</a></span><a id="cardVisual" style="cursor:pointer;float:right" onclick="cardVisual()">编辑</a></div><div id="artitalk_main" style="width:100%;height:100%;padding:1px"></div></div></div>';
    console.log('已挂载card_artitalk');
    parent_div_git.insertAdjacentHTML("afterbegin",item_html);
    (()=>{
      const init = () => {
        new Artitalk(Object.assign({
          appId: '0Iwjb3hh2nIyE2rXULy07JJI-MdYXbMMI',
          appKey: 'WJl1nKnTBO8oq4OhD50MRYBX',
        }, {"serverURL":"https://0iwjb3hh.api.lncldglobal.com","lang":"zh","pageSize":1,"color1":"#49b1f5","color2":"#00c4b6","atEmoji":{"Mafumafu1":"https://cdn.jsdelivr.net/gh/GamerNoTitle/ValineCDN@master/Mafumafu/199749454.png","Mafumafu2":"https://cdn.jsdelivr.net/gh/GamerNoTitle/ValineCDN@master/Mafumafu/199749455.png"}} ))
      }
      if (typeof Artitalk === 'function') {
        init()
      } else {
        getScript('https://cdn.jsdelivr.net/npm/artitalk').then(init)
      }
    })()
    }
  var elist = '/artitalk/,/posts/'.split(',');
  var cpage = location.pathname;
  var epage = 'all';
  var flag = 0;

  for (var i=0;i<elist.length;i++){
    if (cpage.includes(elist[i])){
      flag++;
    }
  }

  if ((epage ==='all')&&(flag == 0)){
    card_artitalk_injector_config();
  }
  else if (epage === cpage){
    card_artitalk_injector_config();
  }
  </script><script async src="https://cdn.jsdelivr.net/npm/hexo-butterfly-artitalk-pro/lib/card_visual.js"></script><!-- hexo injector body_end end --></body></html>